#include<iostream>
#include<string.h>
#define MAX 128
using std::cout;
using std::cin;
using std::endl;

struct Listnode
{
    int val;
    Listnode* next;
};
class Stack
{
public:
    Stack()=default;
    bool empty();
    bool full();
    void push(int);
    void pop();
    int top();
private:
    Listnode* _head=nullptr;
    size_t _all=0;
};

bool Stack::empty()
{
    if(_all==0)
    {
    cout<<"judge empty"<<endl;
        return true;
    }
    cout<<"judge empty"<<endl;
    return false;
}

bool Stack::full()
{
    if(_all==MAX)
    {
        return true;
    }
    cout<<"judge full"<<endl;
    return false;
}

void Stack::push(int a)
{
    if(!full())
    {
        struct Listnode* newnode=new struct Listnode();
        newnode->val=a;
        newnode->next=_head;
        _head=newnode;
        _all++;
        cout<<"head insert"<<endl;
    }
    cout<<"push"<<endl;
}

void Stack::pop()
{
    if(!empty())
    {
        struct Listnode* cur=_head;
        cur=cur->next;
        delete _head;
        _head=cur;
        _all--;
    }
    cout<<"pop"<<endl;
}

int Stack::top()
{
    return _head->val;
}


int main()
{
    Stack s;
    cout<<"empty: "<<s.empty()<<endl;
    s.push(1);
    s.push(2);
    s.push(3);
    s.push(4);
    s.push(5);
    s.push(6);
    s.push(7);
    cout<<"full: "<<s.full()<<endl;
    cout<<"top: "<<s.top()<<endl;
    s.pop();
    s.pop();
    s.pop();
    s.pop();
    s.pop();
    s.pop();
    s.pop();
    s.pop();
    cout<<"empty: "<<s.empty()<<endl;
    s.pop();
    cout<<"empty: "<<s.empty()<<endl;

}

